import request from "@/axios/request";
import url from "@/axios/url";
const { mesUrl, adminUrl } = url();
// 导出url
export const exportUrl = `${mesUrl}mesProdBarcode/export`;
export const exportPrintHisUrl = `${mesUrl}mesBarCodePrintHistory/exportPrintHis`;
export const exportClearingRecordUrl = `${mesUrl}mesProdBarcodeClearLog/exportClearingRecord`;

// ------------------------------ 唯一码明细 --------------------------------------

// 获取子表详情
export function getInfo(id = "") {
  return request({
    url: `${mesUrl}mesProdBarcode/info/${id}`,
    method: "get",
  });
}
// 获取主表详情
export function getMasterInfo(id = "") {
  return request({
    url: `${mesUrl}mesProdBarcode/info/${id}`,
    method: "get",
  });
}
//分页查询
export function getList(params = {}) {
  return request({
    url: `${mesUrl}mesProdBarcode/selectListPageNew`,
    method: "get",
    params,
  });
}

/* 箱码列表-打印 */
export function splitPrintList(params = {}) {
  return request({
    url: `${mesUrl}mesProdBarcode/splitPrintList`,
    method: "get",
    params,
  });
}

/* 清除箱码 */
export function clearBoxcode(data = {}) {
  return request({
    url: `${mesUrl}mesProdBarcode/clearUniqueCode`,
    method: "post",
    data,
  });
}

/* 箱码打印-获取条码数量，已打印、未打印数量 */
export function getBoxCount(data = {}) {
  return request({
    url: `${mesUrl}mesProdBarcode/getBarcodeCount`,
    method: "post",
    data,
  });
}

/* 箱码打印-获取条码数量，已打印、未打印数量 */
export function getBoxCountNes(id) {
  return request({
    url: `${mesUrl}mesProdOrder/info/${id}`,
    method: "get",
  });
}
/* 生码 */
export function creatBoxCode(data = {}) {
  return request({
    url: `${mesUrl}mesProdBarcode/genCode`,
    method: "post",
    data,
  });
}

/* 生码 新 */
export function genCodeAndGetPrintBatch(data = {}) {
  return request({
    url: `${mesUrl}mesProdBarcode/genCodeAndGetPrintBatch`,
    method: "post",
    data,
  });
}

/* 批量生码 */
export function genCodeBatch(data = {}) {
  return request({
    url: `${mesUrl}mesProdBarcode/genCodeBatch`,
    method: "post",
    data,
  });
}

/* 补打查询-（唯一码数量、起止条码 */
export function reprintSel(data = "") {
  return request({
    url: `${mesUrl}mesProdBarcode/reprintSel`,
    method: "post",
    data,
  });
}

/* 补打查询--唯一码列表 */
export function reprintSelList(data = "") {
  return request({
    url: `${mesUrl}mesProdBarcode/reprintSelList`,
    method: "post",
    data,
  });
}
// ------------------------------ 唯一码清除记录 --------------------------------------

//分页查询
export function getUniqueCodeClearList(params = {}) {
  return request({
    url: `${mesUrl}mesProdBarcodeClearLog/selectList`,
    method: "get",
    params,
  });
}

// 行明细
export function uniqueCodeClearRowDetail(id) {
  return request({
    url: `${mesUrl}mesProdBarcodeClearLog/info/${id}`,
    method: "get",
  });
}

// ------------------------------ 唯一码打印记录 --------------------------------------

//分页查询
export function getUniqueCodePrintList(params = {}) {
  return request({
    url: `${mesUrl}mesBarCodePrintHistory/selectList`,
    method: "get",
    params,
  });
}

// 行明细
export function uniqueCodePrintRowDetail(id) {
  return request({
    url: `${mesUrl}mesBarCodePrintHistory/info/${id}`,
    method: "get",
  });
}

// 查询打印条码模板名称列表
export function getBarcodePrintTempList(data = {}) {
  return request({
    url: `${adminUrl}printTemplate/getTempList`,
    method: "post",
    data,
  });
}
// 查询打印条码模板名称列表
export function getTempList(params) {
  return request({
    url: `${adminUrl}system/template/getList`,
    method: "get",
    params,
  });
}

/* 打印模板详情 */
export function printTemplateInfo(id = "") {
  return request({
    url: `${adminUrl}printTemplate/info/${id}`,
    method: "get",
  });
}

// 获取是否
export function getYesOrNot() {
  return request({
    url: `${adminUrl}dict/type/yes_or_not`,
    method: "get",
  });
}

// 查询打印类型：0正常打印 1补码打印(数据字典)列表
export function getPrinttypeList() {
  return request({
    url: `${adminUrl}dict/type/printType`,
    method: "get",
  });
}

// 根据物料查询标签模板/编码规则
export function selectCommonProduceRelByProduce(params) {
  return request({
    url: `${adminUrl}commonProduceTemplateRel/selectCommonProduceRelByProduce`,
    method: "get",
    params,
  });
}

//分页查询
export function mesProdBarcodeReprint(params = {}) {
  return request({
    url: `${mesUrl}mesProdBarcodeReprint`,
    method: "get",
    params,
  });
}

//保存
export function mesProdBarcodeReprintList(data = {}) {
  return request({
    url: `${mesUrl}mesProdBarcodeReprint/insert`,
    method: "post",
    data,
  });
}
//获取补打唯一码
export function selectMesProdBarcodeReprintDetail(id) {
  return request({
    url: `${mesUrl}mesProdBarcodeReprint/selectMesProdBarcodeReprintDetail/${id}`,
    method: "get",
  });
}
//根据配置项编码按层级查询
export function selectListByConfigurationCode(params) {
  return request({
    url: `${adminUrl}commonConfigurationItem/selectListByConfigurationCode`,
    method: "get",
    params,
  });
}
//获取打印次数
export function getPrintingTimes(params) {
  return request({
    url: `${mesUrl}productExtensionProperties/selectOne`,
    // url:
    //   "http://10.10.7.14:10100/mes-service/productExtensionProperties/selectOne",
    method: "get",
    params,
  });
}
//打印 获取未打印列表
export function getPrintList(params) {
  return request({
    url: `${mesUrl}mesProdBarcode/getPrintList`,
    method: "get",
    params,
  });
}
//打印 删除补打申请
export function rowDel(id) {
  return request({
    url: `${mesUrl}mesProdBarcodeReprint/${id}`,
    method: "put",
  });
}
//打印 获取补打申请的明细
export function mesProdBarcodeReprintInfo(id) {
  return request({
    url: `${mesUrl}mesProdBarcodeReprint/info/${id}`,
    method: "get",
  });
}
